using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using MemberMgr.Data.BusinessObjects;
using MemberMgr.Data.Base;

namespace MemberMgr.Data.ManagerObjects
{
    public partial interface ItSystemManager : IManagerBase<tSystem, string>
    {
		// Get Methods
		tSystem GetById(System.String datakbn, System.String datakey);
    }

    partial class tSystemManager : ManagerBase<tSystem, string>, ItSystemManager
    {
		#region Constructors
		
		public tSystemManager() : base()
        {
        }
        public tSystemManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override tSystem GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 2)
				throw new Exception("Invalid Id for tSystemManager.GetById");
			
			return GetById(keys[0], keys[1]);
		}
		public tSystem GetById(System.String datakbn, System.String datakey)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(tSystem));

            criteria.Add(NHibernate.Criterion.Expression.Eq("Datakbn", datakbn));
            criteria.Add(NHibernate.Criterion.Expression.Eq("Datakey", datakey));

            tSystem result = null;

            try
            {
                result = (tSystem)criteria.UniqueResult();
            }
            catch (Exception ex)
            {
                throw;
            }
			

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}